<?php

namespace App\Controller\LazyCommon;

use App\Setting\LazyCommon\WechatAgentCodeSetting;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;

use Symfony\Component\HttpFoundation\Request;
use App\Base\BaseController;
use App\Entity\WechatAgentCode as Entity;

/**
 * @route("/admin/")
 */
class WechatAgentCodeController extends BaseController
{

    /**
     * @route("WechatAgentCode/add",name="WechatAgentCodePreAdd")
     */
    public function add()
    {
        //通用代码
        $this->setSetting(new WechatAgentCodeSetting($this->getDoctrine()->getManager()));
        return $this->comAdd();
    }

    /**
     * @route("WechatAgentCode/add/do",name="WechatAgentCodeDoAdd")
     *
     *
     */
    public function doAdd(Request $request)
    {
        //私有代码
        $entity = new Entity();
        //通用代码
        $this->setSetting(new WechatAgentCodeSetting($this->getDoctrine()->getManager()));
        return $this->comDoAdd($request,$entity);
    }

    /**
     * @route("WechatAgentCode/edit/{id}",name="WechatAgentCodePreEdit")
     */
    public function edit(Entity $entity)
    {
        $this->setSetting(new WechatAgentCodeSetting($this->getDoctrine()->getManager()));
        return $this->comEdit($entity);
    }

    /**
     * @route("WechatAgentCode/edit/{id}/do",name="WechatAgentCodeDoEdit")
     *
     *
     */
    public function doEdit(Request $request,Entity $entity)
    {
        $this->setSetting(new WechatAgentCodeSetting($this->getDoctrine()->getManager()));
        return $this->comDoEdit($request,$entity);
    }

    /**
     * @route("WechatAgentCode",name="WechatAgentCodeLists")
     */
    public function lists()
    {
        //私有部分
        $tools = array();

        //通用部分
        $this->setSetting(new WechatAgentCodeSetting($this->getDoctrine()->getManager()));
        return $this->comLists($tools);
    }


    /**
     * @route("WechatAgentCode/tools",name="WechatAgentCodeTools")
     */
    public function tools(Request $request)
    {
        $this->setSetting(new WechatAgentCodeSetting($this->getDoctrine()->getManager()));
        return $this->comTools($request);
    }

}
